
/** 表格表头 */
export const tableColumns = (t: (msg:string) => string) => [
  {
    prop: 'id',
    type: 'selection',
    label: t('table.selection'),
    width: 55,
    reserveSelection: true,
    fixed: 'left',
  },
  {
    prop: 'id',
    label: t('table.id'),
    minWidth: 100,
    fixed: 'left',
  },
  {
    prop: 'store_id',
    label: t('table.store_id'),
    minWidth: 100,
  },
  {
    prop: 'store_name',
    label: t('table.store_name'),
    minWidth: 100,
  },
  {
    prop: 'money',
    label: t('table.money'),
    minWidth: 120,
  },
  {
    prop: 'type',
    label: t('table.type'),
    minWidth: 120,
  },
  {
    prop: 'addtime',
    label: t('table.addtime'),
    minWidth: 120,
    format: 'date|YYYY-MM-DD HH:mm:ss',
  },
  {
    prop: 'beizhu',
    label: t('table.beizhu'),
    minWidth: 120,
  },
];

/** 表格搜索表单 */
export const tableSearchFormItems = (t: (msg:string) => string) => [
  {
    attrs: {
      label: '门店',
      prop: 'store_id',
    },
    value: '',
    component: {
      is: 'el-select',
      props: {
        placeholder: '请选择门店',
        filterable: true,
      },
    },
    childrenComponent: {
      is: 'el-option',
      children: [{
        label: '充值',
        value: 0,
      }],
    },
  },
  {
    attrs: {
      label: '包含下级',
      prop: 'is_son',
    },
    value: 0,
    component: {
      is: 'el-select',
      props: {
        placeholder: '请选择门店'
      },
    },
    childrenComponent: {
      is: 'el-option',
      children: [
        {
          label: '包含',
          value: 1,
        },
        {
          label: '不包含',
          value: 0,
        }
      ],
    },
  },
  {
    attrs: {
      label: '门店分组',
      prop: 'group_id',
    },
    value: '',
    component: {
      is: 'el-select',
      props: {
        placeholder: '请选择门店',
        filterable: true,
      },
    },
    childrenComponent: {
      is: 'el-option',
      children: [],
    },
  },
  {
    attrs: {
      label: '类型',
      prop: 'type',
    },
    value: '',
    component: {
      is: 'el-select',
      props: {
        placeholder: '请选择类型',
      },
    },
    childrenComponent: {
      is: 'el-option',
      children: () => [
        {
          label: '充值',
          value: 'chongzhi',
        },
        {
          label: '红包',
          value: 'hongbao',
        },
        {
          label: '转出',
          value: 'zhuanchu',
        },
        {
          label: '转入',
          value: 'zhuanru',
        },
      ],
    },
  },
  {
    attrs: {
      label: '添加时间',
      prop: 'date', 
    },
    value: '',
    component: {
      is: 'el-date-picker',
      
      props: {
        type: "datetimerange",
        startPlaceholder: t('search.date.start.placeholder'),
        endPlaceholder: t('search.date.end.placeholder'),
        valueFormat: "YYYY-MM-DD HH:mm:ss",
        defaultTime: [
          new Date(2000, 1, 1, 0, 0, 0),
          new Date(2000, 2, 1, 23, 59, 59),
        ],
        shortcuts: [
          {
            text: t('search.date.shortcuts0'),
            value: () => {
              const end = new Date(new Date().setHours(23,59,59))
              const start = new Date(new Date().setHours(0,0,0))
              // start.setDate(start.getDate() - 7)
              return [start, end]
            },
          },
          {
            text: t('search.date.shortcuts1'),
            value: () => {
              const end = new Date(new Date().setHours(23,59,59))
              const start = new Date(new Date().setHours(0,0,0))
              start.setDate(start.getDate() - 7)
              return [start, end]
            },
          },
          {
            text: t('search.date.shortcuts2'),
            value: () => {
              const end = new Date(new Date().setHours(23,59,59))
              const start = new Date(new Date().setHours(0,0,0))
              start.setMonth(start.getMonth() - 1)
              return [start, end]
            },
          },
          {
            text: t('search.date.shortcuts3'),
            value: () => {
              const end = new Date(new Date().setHours(23,59,59))
              const start = new Date(new Date().setHours(0,0,0))
              start.setMonth(start.getMonth() - 3)
              return [start, end]
            },
          },
        ]
      },
    },
  },
];
